package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Category;

/**
 * 
 * @author 
 *
 */
@DAO
public interface CategoryDAO{
	
	@SQL("SELECT * FROM Category WHERE deleteFlag=1 AND name=:t.name ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<Category> query(@SQLParam("t") Category category);
    
    @SQL("select * from Category where id=:1")
    Category queryById(int id);
    
    @SQL("INSERT INTO Category ("
			        		+ "name,"
			        		+ "deleteFlag,"
			        		+ "createUser,"
			        		+ "createAt,"
			        		+ "updateUser,"
			        		+ "updateAt"
							+") VALUES ("
							+ ":t.name,"
							+ ":t.deleteFlag,"
							+ ":t.createUser,"
							+ ":t.createAt,"
							+ ":t.updateUser,"
							+ ":t.updateAt"
					+")")
    void create(@SQLParam("t") Category category);
	
	@SQL("UPDATE Category SET "
	    			        + "name=:t.name,"
	    			        + "deleteFlag=:t.deleteFlag,"
	    			        + "createUser=:t.createUser,"
	    			        + "createAt=:t.createAt,"
	    			        + "updateUser=:t.updateUser,"
	    			        + "updateAt=:t.updateAt"
    						+ " WHERE id=:t.id")
    void update(@SQLParam("t") Category category);
    
    @SQL("UPDATE Category SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}